package com.hzw.saas.service.product.service;

import java.util.List;
import javax.annotation.Resource;

import com.hzw.saas.api.product.ILicenseProductModuleService;
import com.hzw.saas.api.product.dto.LicenseProductBO;
import com.hzw.saas.api.property.IPropertyService;
import com.hzw.saas.api.property.enmus.SysDictKeyEnum;
import com.hzw.saas.api.property.enmus.SysDictModuleEnum;
import com.hzw.saas.common.util.Json;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * <p>
 *
 * </p>
 *
 * @author yuli
 * @since 2021/6/6 16:42
 */
@Service
@RequiredArgsConstructor
@Slf4j
public class LicenseProductModuleServiceImpl implements ILicenseProductModuleService {

    @Resource(name = IPropertyService.SYS_DICT_BEAN)
    private IPropertyService<SysDictKeyEnum> propertyService;

    @Override
    public List<LicenseProductBO> listLicenseByLevel(String prodId, String levelId) {
        String value = propertyService.getPropertyValue(SysDictModuleEnum.PRODUCT_MODULE_LICENSE.getModule(),
            String.format("%s-%s", prodId, levelId));
        return Json.parseArray(value, LicenseProductBO[].class);
    }
}
